<template>
  <panel>

    <!--按钮 复制-->
    <el-row class="operate-wrap">
      <el-col :span="24">
        <el-button type="info" size="small"  @click="submitForm('ruleForm')">保存</el-button>
        <span class="remove-box">
          <el-button size="small" onclick="history.go(-1)">返回</el-button>
        </span>
      </el-col>
    </el-row>
    <!--按钮 复制-->

    <el-row>
      <el-col :span="24" class="form-wrap">
        <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="60px" :label-position="'left'">
          <el-form-item label="用户姓名" prop="name" class="item-5">
            <el-input v-model="ruleForm.userName" size="small"></el-input>
          </el-form-item>
          <el-form-item label="创建人" prop="creater" class="item-5">
            <el-input v-model="ruleForm.creater" size="small"></el-input>
          </el-form-item>
          <el-form-item label="证件类型" prop="certificateType" class="item-5">
            <el-select v-model="ruleForm.certificateType" size="small" placeholder="请选择证件类型">
              <el-option label="身份证" value="shanghai"></el-option>
              <el-option label="港澳通行证" value="beijing"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="证件号码" prop="certificate" class="item-5">
            <el-input v-model="ruleForm.certificate" size="small"></el-input>
          </el-form-item>
          <el-form-item label="电话" prop="phone" class="item-5">
            <el-input v-model="ruleForm.phone" size="small"></el-input>
          </el-form-item>
          <el-form-item label="地址" prop="address" class="item-5">
            <el-input v-model="ruleForm.address" size="small"></el-input>
          </el-form-item>
          <el-form-item label="active" prop="active" class="item-5">
            <el-radio-group v-model="ruleForm.active">
              <el-radio label="激活"></el-radio>
              <el-radio label="取消激活"></el-radio>
            </el-radio-group>
          </el-form-item>
          <el-form-item label="唯一GUID" prop="guid" class="item-5">
            <el-input  v-model="ruleForm.guid" size="small"></el-input>
          </el-form-item>
        </el-form>
      </el-col>
    </el-row>
  </panel>
</template>

<script>
  export default {
    data() {
      return {
        ruleForm: {
          userName: '',
          creater: '',
          certificateType:'',
          certificate:'',
          phone:'',
          active:'',
          guid:'',
        },
        rules: {
          //required: true 为 必填项 注意html 加 * 号
          name: [
            { required: true, message: '请输入活动名称', trigger: 'blur' },
            { min: 3, max: 5, message: '长度在 3 到 5 个字符', trigger: 'blur' }
          ],
          creater: [
            { required: true, message: '请输入活动名称', trigger: 'blur' },
            { min: 3, max: 5, message: '长度在 3 到 5 个字符', trigger: 'blur' }
          ],
          certificateType: [
            { required: true, message: '请选择活动区域', trigger: 'change' }
          ],
          certificate: [
            { required: true, message: '请输入活动名称', trigger: 'blur' },
            { min: 3, max: 5, message: '长度在 3 到 5 个字符', trigger: 'blur' }
          ],
          phone: [
            { required: true, message: '请输入活动名称', trigger: 'blur' },
            { min: 3, max: 5, message: '长度在 3 到 5 个字符', trigger: 'blur' }
          ],
          address: [
            { required: true, message: '请输入活动名称', trigger: 'blur' },
            { min: 3, max: 5, message: '长度在 3 到 5 个字符', trigger: 'blur' }
          ],
          active: [
            { required: true, message: '请选择活动资源', trigger: 'change' }
          ],
          guid: [
            { required: true, message: '请输入活动名称', trigger: 'blur' },
            { min: 3, max: 5, message: '长度在 3 到 5 个字符', trigger: 'blur' }
          ]
        }
      }
    },
    methods: {
      submitForm(formName) {
        this.$refs[formName].validate((valid) => {
          if (valid) {
            alert('submit!');
          } else {
            console.log('error submit!!');
            return false;
          }
        });
      },
      resetForm(formName) {
        this.$refs[formName].resetFields();
      },
    }
  }
</script>
<style>

</style>
